package com.lyy.mapper;

import com.lyy.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


/**
 * @author Liangyaoyun
 */
@Mapper
public interface ProductMapper {
    /***
     * 根据主键查询商品信息
     * @param id 商品主键
     * @return 商品信息
     */
    @Select("select `id`, `title`, `stock` from `product` where `id` = #{param1}")
    Product selectById(Long id);
    /**
     * 根据主键修改商品库存
     *
     * @param product 商品实体
     */
    @Update("UPDATE `product` SET stock = #{stock} WHERE `id` = #{id}")
    Long updateStock(Product product);
}
